package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.hsc.pcddfivepcdd.R;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.model.UserBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyDialog1;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.HashMap;
import okhttp3.Call;

public class EditDataActivity extends BaseActivity
{
  private String TAG = "EditDataActivity";
  private ImageView btn_modify;
  private Context context;
  private EditText edit_ge_qian;
  private EditText edit_nick_name;
  private String guid = "";
  private GridView gv_home;
  private ImageView iv_title_right;
  private MyDialog1 myDialog1;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
        CustomApplication.app.finishActivity(EditDataActivity.this);
        return;
      case 2131099855:
      }
      EditDataActivity.this.postData();
      EditDataActivity.this.closeWindowSoftInput(EditDataActivity.this.btn_modify);
    }
  };
  private TextView tv_user_name;
  private String userGeQian = "";
  private String userNickName = "";
  private View view_title;

  private void init()
  {
    this.myDialog1 = new MyDialog1(this.context);
    this.tv_user_name = ((TextView)findViewById(2131099852));
    this.edit_nick_name = ((EditText)findViewById(2131099853));
    this.edit_ge_qian = ((EditText)findViewById(2131099854));
    this.btn_modify = ((ImageView)findViewById(2131099855));
    this.btn_modify.setOnClickListener(this.onClickListener);
    if (CustomApplication.app.userBaseBean != null)
    {
      String str1 = CustomApplication.app.userBaseBean.getUser_name();
      String str2 = CustomApplication.app.userBaseBean.getNick_name();
      String str3 = CustomApplication.app.userBaseBean.getSignature();
      this.guid = CustomApplication.app.userBaseBean.getGuid();
      if (str1 != null)
        this.tv_user_name.setText(str1);
      if (str2 != null)
        this.edit_nick_name.setText(str2);
      if (str3 != null)
        this.edit_ge_qian.setText(str3);
    }
  }

  private void postData()
  {
    this.userNickName = this.edit_nick_name.getText().toString();
    this.userGeQian = this.edit_ge_qian.getText().toString();
    if ("".equals(this.userNickName))
    {
      ShowDialog1("请输入您的昵称");
      return;
    }
    if (this.userGeQian.length() > 20)
    {
      UiUtil.showToast(this.context, "个签不能超过20个字");
      return;
    }
    HashMap localHashMap = new HashMap();
    localHashMap.put("nick_name", this.userNickName);
    localHashMap.put("signature", this.userGeQian);
    localHashMap.put("guid", this.guid);
    LogUtils.i(this.TAG, "userNickName:" + this.userNickName);
    LogUtils.i(this.TAG, "userGeQian:" + this.userGeQian);
    LogUtils.i(this.TAG, "url:" + AppConstants.URL_CHANGE_USER_INFO);
    showLoadingDialog();
    setSureBtnIsEnable(false);
    RequestNet.post(this.context, AppConstants.URL_CHANGE_USER_INFO, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        EditDataActivity.this.dismissLoadingDialog();
        EditDataActivity.this.setSureBtnIsEnable(true);
        LogUtils.e("返回失败", "result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        EditDataActivity.this.dismissLoadingDialog();
        EditDataActivity.this.setSureBtnIsEnable(true);
        LogUtils.d("返回成功", "result:" + paramAnonymousString);
        Gson localGson = new Gson();
        try
        {
          localUserBean = (UserBean)localGson.fromJson(paramAnonymousString, UserBean.class);
          if (localUserBean == null)
          {
            EditDataActivity.this.ShowDialog1("修改失败");
            return;
          }
        }
        catch (Exception localException)
        {
          UserBean localUserBean;
          do
          {
            while (true)
            {
              localException.printStackTrace();
              localUserBean = null;
            }
            if (localUserBean.getFlag() == 0)
            {
              EditDataActivity.this.ShowDialog1(localUserBean.getMsg());
              return;
            }
            if (localUserBean.getFlag() == -2)
            {
              EditDataActivity.this.showDownWireDialog();
              return;
            }
            if (localUserBean.getFlag() == -3)
            {
              EditDataActivity.this.ShowFengjinDialog();
              return;
            }
            if (localUserBean.getFlag() == -4)
            {
              EditDataActivity.activityStack.backToMain(MainActivity.class, EditDataActivity.this.context);
              return;
            }
            if (localUserBean.getFlag() == 2)
            {
              EditDataActivity.this.ShowDialog1(localUserBean.getMsg());
              return;
            }
          }
          while (localUserBean.getFlag() != 1);
          UserBaseBean localUserBaseBean = localUserBean.getResult();
          if (localUserBaseBean != null)
          {
            CustomApplication.app.userBaseBean.setNick_name(localUserBaseBean.getNick_name());
            CustomApplication.app.userBaseBean.setSignature(localUserBaseBean.getSignature());
          }
          EditDataActivity.this.myDialog1.show();
          EditDataActivity.this.myDialog1.setMessage("修改成功");
          EditDataActivity.this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener()
          {
            public void onClick(View paramAnonymous2View)
            {
              EditDataActivity.this.myDialog1.dismiss();
              CustomApplication.app.finishActivity(EditDataActivity.class);
            }
          });
          EditDataActivity.this.closeWindowSoftInput(EditDataActivity.this.edit_ge_qian);
        }
      }
    });
  }

  private void setSureBtnIsEnable(boolean paramBoolean)
  {
    if (paramBoolean)
      this.btn_modify.setBackgroundResource(2130838215);
    while (true)
    {
      this.btn_modify.setEnabled(paramBoolean);
      return;
      this.btn_modify.setBackgroundResource(2130838087);
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.activity_edit_data);
    CustomApplication.app.addActivity(this);
    this.context = this;
    setTitle(8, 0, 2130837809, "修改资料", 0, 8, 8, 0, true);
    init();
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
    closeWindowSoftInput(this.edit_ge_qian);
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.EditDataActivity
 * JD-Core Version:    0.6.2
 */